namespace Peninsula.DataAccess.EF.SqlServer.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _006 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.RepairOrder",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 50),
                        Nams = c.String(maxLength: 150),
                        Description = c.String(maxLength: 200),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        Status = c.Byte(nullable: false),
                        Appointment = c.DateTime(nullable: false),
                        EndTime = c.DateTime(nullable: false),
                        MMessage = c.String(maxLength: 200),
                        ItemTypeId = c.String(maxLength: 50),
                        StoreId = c.String(maxLength: 50),
                        MaintenanceStaffId = c.String(maxLength: 50),
                        IsDeleted = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false),
                        UpdatedTime = c.DateTime(),
                        UpdatedBy = c.String(nullable: false, maxLength: 50),
                        CreatedBy = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ItemType", t => t.ItemTypeId)
                .ForeignKey("dbo.Admin", t => t.MaintenanceStaffId)
                .ForeignKey("dbo.Store", t => t.StoreId)
                .Index(t => t.ItemTypeId)
                .Index(t => t.StoreId)
                .Index(t => t.MaintenanceStaffId);
            
            CreateTable(
                "dbo.SiteFile",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 50),
                        Path = c.String(nullable: false, maxLength: 500),
                        Title = c.String(maxLength: 200),
                        Description = c.String(),
                        Type = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false),
                        UpdatedTime = c.DateTime(),
                        UpdatedBy = c.String(nullable: false, maxLength: 50),
                        CreatedBy = c.String(nullable: false, maxLength: 50),
                        RepairOrder_Id = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.RepairOrder", t => t.RepairOrder_Id)
                .Index(t => t.RepairOrder_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.RepairOrder", "StoreId", "dbo.Store");
            DropForeignKey("dbo.SiteFile", "RepairOrder_Id", "dbo.RepairOrder");
            DropForeignKey("dbo.RepairOrder", "MaintenanceStaffId", "dbo.Admin");
            DropForeignKey("dbo.RepairOrder", "ItemTypeId", "dbo.ItemType");
            DropIndex("dbo.SiteFile", new[] { "RepairOrder_Id" });
            DropIndex("dbo.RepairOrder", new[] { "MaintenanceStaffId" });
            DropIndex("dbo.RepairOrder", new[] { "StoreId" });
            DropIndex("dbo.RepairOrder", new[] { "ItemTypeId" });
            DropTable("dbo.SiteFile");
            DropTable("dbo.RepairOrder");
        }
    }
}
